home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 3 / BBS in a box - Trilogy III.iso / Files / Bus / T-Z / VCR+(app+src) Folder / Sources / encoder.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-03-17  |  1.2 KB  |  55 lines  |  [TEXT/KAHL]

  1. #include "VCRplus.h"
  2.  
  3. extern    vcrInfo    myVCR;
  4.  
  5. void encoder(void)
  6. {
  7.     long     j, doneflag, tblidx ;
  8.     long     s1_out, bot3, top5, quo, rem ;
  9.     long     s4_out, s5_out, ofout ;
  10.     Str32    codeText;
  11.  
  12.  
  13.     /* get the  t  bits and the  c  bits */
  14.     tblidx = lookup2(myVCR.startTime, myVCR.duration);
  15.  
  16.     /* from them infer what must have been step 4 & step 5 results */
  17.     interleave(tblidx, myVCR.channel - 1, (&s4_out), (&s5_out)) ;
  18.  
  19.     /* find the smallest unmapped_top giving correct mapped_top */
  20.     top5 = 0;
  21.     doneflag = 0;
  22.  
  23.     /* if the mapped_top is zero then top and offset are zero */
  24.     if(s4_out == 0) { top5 = 0; ofout = 0; doneflag = 1; }
  25.  
  26.     while(doneflag == 0)
  27.     {
  28.         top5++;
  29.         offset(myVCR.day, myVCR.year, top5, (&ofout), (&j)) ;
  30.         if(j == s4_out) doneflag = 1;
  31.     }
  32.  
  33.     /* have two of the three inputs to step 5; determine the rem */
  34.     for(rem=0; rem<32; rem++)
  35.     {
  36.         j = (rem + (myVCR.day*(myVCR.month+1)) + ofout) % 32 ;
  37.         if(j == s5_out) break ;
  38.     }
  39.     quo = (myVCR.day - 1);
  40.  
  41.  
  42.     /* assemble the output of step 1 */
  43.     bot3 = 1 + rem + (32 * quo) ;
  44.     s1_out = bot3 + (1000 * top5) ;
  45.  
  46.     /* invert the mixing */
  47.     myVCR.code = f1(s1_out);
  48.     NumToString(myVCR.code, codeText);
  49.     
  50.     SetDText(dlgPLUSCODE, codeText);
  51.  
  52.     return;
  53. }
  54.  
  55.